<?php if ($action == Form::ACTION_EDIT) { ?>
<fieldset class="form-fieldset">
  <legend><?php echo $title ?></legend>
  <span class="form-element-body">
<?php } ?>

<?php echo $this->form->checkboxes($options, $values, array('class' => $rowClass), array('itemSeparator' => '<br/>')); ?>

<?php if ($action == Form::ACTION_EDIT) { ?>
  </span>
</fieldset>
<?php } ?>

<script>
$(document).ready(function() {
  $('.<?php echo $rowClass ?>').click(function() {
    var data = {
      action: 'toggle',
      <?php echo $name ?>: <?php echo $value ?>,
      <?php echo $key ?>: $(this).val(),
      checked: $(this).attr('checked') ? 1 : 0
    };

    var url = '<?php echo Simplify::response()->makeUrl($route) ?>';

    //$.amp.loadBegin();

    $.post(url, data, function(response) {
      //alert(response);
      //$.amp.loadEnd();
      //$.amp.isError(response);
    });
  });
});
</script>